<?php
/*
 * Created by generator
 *
 */

class ListtrancheAges extends Controller {

	/**
	 * Constructeur
	 */
	function ListtrancheAges(){
		parent::Controller();
		$this->load->model('trancheAge_model');
		$this->load->library('session');
		$this->load->helper('url');
	}

	/**
	 * Affichage des trancheAges
	 */
	public function index(){
		$data['trancheages'] = trancheAge_model::getAlltrancheAges($this->db);
		$this->load->view('listtrancheages_view', $data);
	}

	/**
	 * Ajout d'un trancheAge
	 */
	public function add(){

		// Insertion en base
		$model = new trancheAge_model();
		$model->traidtra = $this->input->post('traidtra'); 
		$model->tralbnom = $this->input->post('tralbnom'); 
		$model->save($this->db);

		$this->session->set_flashdata('message', 'Nouveau trancheAge ajoute');
		
		// Recharge la page avec les nouvelles infos
		redirect('listtrancheages/index'); 
	}

	/**
	 * Suppression d'un trancheAge
	 * @param $traidtra identifiant a supprimer
	 */
	function delete($traidtra){
		trancheAge_model::delete($this->db, $traidtra);

		$this->session->set_flashdata('message', 'trancheAge supprime');

		redirect('listtrancheages/index'); 
	}

}
?>
